home *** CD-ROM | disk | FTP | other *** search
- {BlueBag and AtSayGet procedure demonstration. Each new feature demonstrated
- in the source code is followed by the word DEMO so you can examine how it is
- used. Not all the procedures are demonstrated but there is a good representa-
- tion. See ReadDemo.PAS for a demonstration of the full screen editor.}
-
- PROGRAM Demo;
-
- {$V-}
- USES
- CRT,
- AtSayGet,
- BlueBag;
-
- TYPE
- PhoneType = STRING[14];
-
- VAR
- AllOK : BOOLEAN;
- DS1,
- DS2 : DateString;
- Dt1,
- Dt2 : Date;
- BigDt : DelimitedDate;
- Change: LONGINT;
- Str10 : STRING[10];
- AnyS : STRING;
- Doc : TEXT;
- Age : WORD;
-
- CONST
- Cont : BOOLEAN =True;
- Phone : PhoneType='( ) - ';
- AR : REAL =0.0;
- LI : LONGINT =0;
- I : INTEGER =0;
- W : WORD =0;
-
- BEGIN
- ClrScr;
- AtSay(20, 5,'AtSayGet and BlueBag TPU Demo'); {DEMO}
- ReverseVideo; {DEMO}
- GoToXY(22, 6); WRITE('Oh look -- Reverse video!'); DELAY(3000);
- RestoreVideo; {DEMO}
- CursorOff; {DEMO}
- AtSay(22,10,'Heh...Where''s the cursor?'); Delay(3000);
- CursorOn; {DEMO}
- SetCursor(0,StopScan); {DEMO}
- AtSay(19,11,'Isn''t this a bit over doing it?'); Delay(3000);
- RestoreCursor; {DEMO}
- GoToXY(1,20);
- WAIT; {DEMO}
- OpenWindow(5,5,70,12,White,Red,2,' STRING ROUTINES '); {DEMO}
- WRITELN;
- WRITELN(' (The image below this window was just saved on the heap)');
- WRITE(' '); WAIT; ClrScr;
- WRITELN('Please enter a line of text in lower case & press Enter:');
- READLN(AnyS);
- WRITELN('This demonstrates the UpperCase Function -');
- WRITELN(UpperCase(AnyS)); {DEMO}
- WAIT; ClrScr;
- WRITELN('After NoBlanks() takes care of your line it looks like this:');
- NoBlanks(AnyS); {DEMO}
- WRITELN(AnyS);
- WAIT; WRITELN;
- WRITELN('The Trim() Function also works but it''s hard to');
- WRITELN('demonstrate visually. See line 104 for a demo.'); WAIT;
- OpenWindow(1,1,50,22,Black,LightGray,32,' SCREEN TRICKS ');
- WRITELN('Here goes DrawBox()!'); Wait;
- DrawBox(1,4,47,19,1); Delay(500); {DEMO}
- DrawBox(5,2,22,12,2); Delay(500);
- DrawBox(10,15,40,18,240); Delay(500);
- DrawBox(15,5,45,20,219);
- GoToXY(2,13); WAIT; ClrScr;
- AnyS:='This big line of text will fill all the screen.';
- FOR Change:=1 TO 20 DO WRITELN(AnyS);
- WRITELN('Now to test the Clear() procedure...'); WAIT;
- Clear(2,2,30,11); {DEMO}
- GoToXY(4,4); WRITE('Clear() works!');
- GoToXY(4,5); WAIT;
- OpenWindow(10,12,80,20,White+Blink,Blue,1,' AtSayGet PROCEDURES ');
- DEC(TextAttr,Blink);
- OrgAttr:=31; SayAttr:=23; GetAttr:=112; EndAttr:=31; {DEMO}
- WRITELN('The AtSayGet unit provides the functional equivalence of the');
- WRITELN('dBase: @ Line,Row SAY "prompt" GET <var> [PICTURE] [RANGE]');
- WRITELN('command. A full range of editing keys are employed. See the');
- WRITELN('ATSAYGET.DOC file for details.');
- AtSayGetBoolean(2,6,'Continue?',Cont); {DEMO}
- WRITELN;
- IF NOT Cont THEN
- BEGIN
- WRITE(' I insist!'); Delay(2000);
- END;
- ClrScr; AnyS:='';
- REPEAT
- AtSay(2,1,'Do not leave this field blank, or else!'); {you won't ever finish}
- AtSayGetStrLen(2,2,'What is your name?',AnyS,30); {DEMO}
- UNTIL NOT IsBlank(AnyS); {DEMO}
- GoToXY(2,1); ClrEol;
- AtSayGetWord (2,3,'What is your age? ',W,2); {DEMO}
- AtSayGetStrPic(2,5,'What is your phone',Phone,'(999) 999-9999'); {DEMO}
- AtSayGetInt (2,6,'Enter an Integer ',I,5); {DEMO}
- I:=0; ClrScr;
- {the following shows some of the ASGRange procedures}
- WRITELN('O.K. ',TRIM(AnyS),', let''s not have any negative numbers!'); {DEMO}
- AtSayGetIntRange(2,4,'What do you owe on your car?',I,6,0,MaxInt); {DEMO}
- AtSayGetLongIntRange(2,5,'What is owing on your house?',LI,7,0,250000); {DEMO}
- AtSayGetRealRange(2,6,'What are your living costs? ',AR,10,2,500,5000); {DEMO}
- WRITELN; WAIT;
- OpenWindow(20,15,75,22,White,Black,240,' DEVICE FUNCTIONS ');
- OrgAttr:=15; SayAttr:=7; GetAttr:=112; EndAttr:=15;
- Cont:=True;
- WHILE Cont DO
- BEGIN
- ClrScr; WRITELN;
- FOR W:=0 TO 2 DO
- BEGIN
- WRITE(' Your printer #',W+1:2,' is ');
- IF PrinterOnLine(W) THEN WRITELN('on-line.') ELSE WRITELN('NOT on-line.');
- {DEMO ^}
- END;
- AtSayGetBoolean(2,6,'Try again?',Cont);
- END;
- ClrScr;
- OpenWindow(12,3,68,18,White,Black,1,' DATE FEATURES ');
- ClrScr; AllOK:=False;
- Dt2:=SysDate; {DEMO}
- Ds2:=DateToDateString(Dt2); {DEMO}
- WRITELN(' Today is ',DayName[DayOfWeek(Dt2)],', ',MonthName[MonthOfYear(Dt2)],
- ' ',COPY(Ds2,3,2),', ',COPY(Ds2,5,4)); {DEMO of 2 functions}
- REPEAT
- BigDt:=' / / ';
- AtSayGetStrPic(2,2,'Enter Birth Day as Mo/Dy/Year:',BigDt,'99/99/9999');
- WRITELN;
- Ds1:=StripDateString(BigDt); {DEMO}
- Dt1:=DateStringToDate(Ds1); {DEMO}
- IF Dt1<>BadDate THEN AllOK:=True ELSE
- BEGIN
- WRITELN(' You entered an invalid date. Please try again.'); WAIT; CLEAR(1,2,48,4);
- END;
- UNTIL AllOK;
- WRITELN(' You were born on a ',DayName[DayOfWeek(Dt1)]);
- WRITELN(' Gosh, that was ',DaysBetween(Dt1,Dt2),' days ago!');
- Age:=Trunc((Dt2-Dt1) / 365.25);
- WRITE(' You were ',Age,' years old ');
- WRITELN((Dt2-Dt1)-Trunc(Age*365.25),' days ago.'); Dt1:=0;
- AtSayGetLongIntRange(2,7,'Enter some number of days hence: ',Dt1,6,0,999999);
- WRITELN;
- IncDate(Dt2,Dt1); {DEMO}
- Ds2:=DateToDateString(Dt2);
- BigDt:=DelimitDateString(DS2); {DEMO}
- WRITELN(' The date that is ',Dt1,' days from now is ',BigDt);
- WRITELN(' That will be a ',DayName[DayOfWeek(Dt2)],' in ',MonthName[MonthOfYear(Dt2)]);
- WRITELN;
- WRITELN(' These date routines are only usefull until ',
- DelimitDateString(DateToDateString(3652499)));
- WRITELN(' Sorry.'); WAIT;
- CloseWindow; {Date Features}
- AnyS:='BLUEBAG.DOC '; Cont:=True;
- WHILE Cont DO
- BEGIN
- ClrScr;
- AtSayGetStrLen(2,2,'Enter a file name',AnyS,12); GoToXY(2,4);
- WRITE(Trim(AnyS));
- IF OnFile(AnyS) THEN WRITELN(' is on file.') ELSE WRITELN(' is NOT on file.');
- {DEMO ^}
- AtSayGetBoolean(2,5,'Try again?',Cont);
- END;
- ClrScr; Cont:=True;
- AtSayGetBoolean(2,3,'Read the documentation now?',Cont); WRITELN;
- IF Cont THEN
- BEGIN
- IF OnFile('BLUEBAG.DOC') OR OnFile('ATSAYGET.DOC') THEN
- BEGIN
- OpenWindow(1,1,80,24,LightGray,Black,1,' DOCUMENTATION ');
- IF OnFile('BLUEBAG.DOC') THEN
- BEGIN
- ASSIGN(Doc,'BLUEBAG.DOC'); RESET(Doc); I:=1;
- WHILE NOT EOF(Doc) DO
- BEGIN
- Readln(Doc,AnyS); WRITELN(AnyS); INC(I);
- IF I=21 THEN
- BEGIN
- WAIT; GoToXY(1,WhereY); ClrEol; I:=1;
- END;
- END;
- CLOSE(Doc); WAIT; ClrScr;
- END
- ELSE
- BEGIN
- WRITELN('BLUEBAG.DOC IS NOT ON FILE.'); WAIT;
- END;
- ClrScr;
- IF OnFile('ATSAYGET.DOC') THEN
- BEGIN
- ASSIGN(Doc,'ATSAYGET.DOC'); RESET(Doc); I:=1;
- WHILE NOT EOF(Doc) DO
- BEGIN
- Readln(Doc,AnyS); WRITELN(AnyS); INC(I);
- IF I=21 THEN
- BEGIN
- WAIT; GoToXY(1,WhereY); ClrEol; I:=1;
- END;
- END;
- CLOSE(Doc); WAIT; ClrScr;
- END
- ELSE
- BEGIN
- WRITELN('ATSAYGET.DOC IS NOT ON FILE.'); WAIT;
- END;
- CloseWindow;
- END
- ELSE
- BEGIN
- WRITELN('Rats, both document files are missing!'); Wait;
- END;
- END;
- CloseWindow; {DEMO}
- Delay(500);
- CloseWindow; Delay(500);
- CloseWindow; Delay(500);
- CloseWindow;
- IF IsColor THEN TextAttr:=30 ELSE TextAttr:=7; {DEMO}
- SayAttr:=TextAttr;
- AtSay(1,24,'Well, how''s that?');
- END.
-